﻿using MSAcademic.v2.Infrastructure.Article;
using MSAcademic.v2.Infrastructure.Search;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MSAcademic.v2.Web.Models
{
    public partial class SearchModel
    {
        public string Title { get; set; }
        public bool IsPost { get; set; }
    }

    public partial class SearchModel
    {
        public IEnumerable<IArticle> SearchList
        {
            get
            {
                if (_searchList == null)
                {
                    _searchList = new Lazy<IEnumerable<IArticle>>(() => _searchQueries.SearchAllArticles(Title));
                }
                return _searchList.Value;
            }
        }
        private Lazy<IEnumerable<IArticle>> _searchList;
    }

    public partial class SearchModel
    {
        private readonly ISearchQueries _searchQueries;

        public SearchModel(
            ISearchQueries searchQueries)
        {
            _searchQueries = searchQueries;
        }
    }
}